<%@ page language="java"  pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/views/common/taglib.jsp" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>修改配送员信息</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="viewport" content="width=320.1, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <%@ include file="/WEB-INF/views/common/resource.jsp" %>
</head>
<body>
<div class="page pt0 form">
    <h2>配送员姓名：</h2>
    <div class="input_box">
        <input id="courier_name" value="${courier.courier_name}" type="text"  />
    </div>
    <h2>配送员电话：</h2>
    <div class="input_box">
        <input id="mobile" type="text" value="${courier.courier_mobile}"  maxlength="11" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') " />
    </div>
    <div class="bottom_btns" onclick="saveCourier()">确认修改</div>
</div>
</body>

<script>
    
    function saveCourier() {
        var courier_name = $('#courier_name').val();

        if(checkIsNull(courier_name)){
            alertTips("请填写姓名！");
            return false;
        }

        var mobile = $('#mobile').val();

        if(checkIsNull(mobile)){
            alertTips("请填写手机号！");
            return false;
        }

        if(!(/^1[34578]\d{9}$/.test(mobile))){
            alert("手机号格式不正确，请重填");
            return false;
        }

        $.ajax({
            type: "post",
            url: ctx+'/mep/editCourier.do',
            dataType: "json",
            data: {
                'mobile' : '${courier.courier_mobile}',
                'new_mobile' : mobile,
                'courier_name' : courier_name,
                'courier_id' : ${courier.courier_id}
            },
            success: function(resp){
                console.log(resp);
                if(resp.result==="success"){
                    alertTips("修改配送员信息成功！");
                    location.href=ctx+'/mep/toCourierDetail.do?courier_id=${courier.courier_id}';
                }else{
                    alertTips(resp.msg);
                }
            }
        });

    }
    
    
</script>
</html>
